﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Web4Comment.SNSAPI
{
   

    public class SnsBase
    {
        
        #region Fields
        /// <summary>
        /// App Key
        /// </summary>
        public string App_Key { get; set; }
        /// <summary>
        /// App Secret
        /// </summary>
        public string App_Secret { get; set; }
        /// <summary>
        /// 授权后要回调的URI，即接受code的URI。
        /// </summary>
        public string Redirect_Uri { get; set; }
        /// <summary>
        /// Post/Get方法
        /// </summary>
        public IHttpMethod HttpMethod { get; private set; }

        /// <summary>
        /// baseUrl
        /// </summary>
        public readonly string baseUrl = "https://api.weibo.com/2/{0}";
        /// <summary>
        /// 请求用户授权Token
        /// </summary>
        public readonly string authorizeUrl = "https://api.weibo.com/oauth2/authorize";
        /// <summary>
        /// 获取授权过的Access Token
        /// </summary>
        public readonly string tokenUrl = "https://api.weibo.com/oauth2/access_token";

        public string sns_name { get; set; }
        /*
        /// <summary>
        /// 请求OAuth服务返回包括Access Token等消息
        /// </summary>
        public AccessToken Token
        {
            get
            {
                if (HttpContext.Current != null)
                {
                    _Token = null;
                    if (HttpContext.Current.Session["access_token"] != null)
                    {
                        _Token = HttpContext.Current.Session["access_token"] as AccessToken;
                    }
                    return _Token;
                }
                else
                {
                    return _Token;
                }
            }
            protected set
            {
                if (HttpContext.Current != null)
                {
                    HttpContext.Current.Session["access_token"] = value;
                }
                else
                {
                    _Token = value;
                }
            }
        }
        */
        #endregion

        public SnsBase(string app_key, string app_secret, string redirect_uri)
        {
            this.App_Key = app_key;
            this.App_Secret = app_secret;
            this.Redirect_Uri = redirect_uri;
            this.HttpMethod = new HttpMethods();
        }
        public SnsBase()
            : this(string.Empty, string.Empty, string.Empty)
        { }

    }
}
